const util = require("../../utils/util")
const app = getApp();

Page({
  data: {
  },

  formReset(e) {
    console.log('form发生了reset事件，携带数据为：', e.detail.value)
  },

  formSubmit(e) {
    //新订单提交
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
    wx.request({
      //将创建的订单信息传入后端
      url: util.BASE_URL + "/get/orderlist", 
      method: "POST",
      data: {
        address: e.detail.value.address,
        remark: e.detail.value.remark,
        packed: e.detail.value.packed,
        customerId: app.globalData.userInfo.id
      },
      success(res) {
        //将后端数据库生成的订单号打包成对象返回给前端，放入前端全局变量orderList
        app.globalData.orderList = res.data
        console.log('从后端拿到订单:',app.globalData.orderList)
      }
    })
    // 跳入选择商品页面
    wx.navigateTo({
      url: '/pages/order/order',
    })
  },

})